package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.ServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author hu
 * @date 2025/3/13
 */
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 区域服务相关接口")
public class ServeController {

    @Autowired
    private ServeService serveService;

    @GetMapping("/page")
    @ApiOperation("区域服务分页查询")
    public PageResult<ServeResDTO> pageSelect(ServePageQueryReqDTO servePageQueryReqDTO) {
        PageResult<ServeResDTO> pageResult = serveService.pageSelect(servePageQueryReqDTO);
        return pageResult;
    }


    @PostMapping("/batch")
    @ApiOperation("添加区域服务")
    public void add(@RequestBody List<ServeUpsertReqDTO> dtos) throws Exception {
        serveService.batchAdd(dtos);
    }


    @PutMapping("/{id}")
    @ApiOperation("区域服务价格修改")
    public void update(@PathVariable Long id, BigDecimal price) {
        serveService.updatePriceById(id, price);
    }

    @PutMapping("/onSale/{id}")
    @ApiOperation("上架区域服务")
    public void Shelves(@PathVariable Long id) {
        serveService.ShelvesServe(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除区域ID")
    public void delete(@PathVariable Long id) {
        serveService.deleteServe(id);
    }

    @PutMapping("/offSale/{id}")
    @ApiOperation("下架区域服务")
    public void offSale(@PathVariable Long id) {
        serveService.offSale(id);
    }

    @PutMapping("/onHot/{id}")
    @ApiOperation("设置热门")
    public void onHot(@PathVariable Long id) {
        serveService.onHot(id);
    }

    @PutMapping("/offHot/{id}")
    @ApiOperation("取消热门")
    public void offHot(@PathVariable Long id) {
        serveService.offHot(id);
    }

}
